package entity

import "sync/atomic"

type runSum struct {
	ConnOk           *int32 //连接成功
	XtUp             *int32 //上传心跳数
	XtBack           *int32 //心跳确认数
	ServerCmd        *int32 //服务器指令
	ServerCmdConfirm *int32 //服务器指令确认
}

var (
	t1, t2, t3, t4, t5 int32

	RunSum = &runSum{
		ConnOk:           &t1,
		XtUp:             &t2,
		XtBack:           &t3,
		ServerCmd:        &t4,
		ServerCmdConfirm: &t5,
	}
)

func AddConnOk(delta int32) {
	if delta < 0 && *RunSum.ConnOk < 1 {
		return
	}
	atomic.AddInt32(RunSum.ConnOk, delta)
}
func AddXtUp(delta int32) {
	if delta < 0 && *RunSum.XtUp < 1 {
		return
	}
	atomic.AddInt32(RunSum.XtUp, delta)
}
func AddXtBack(delta int32) {
	if delta < 0 && *RunSum.XtBack < 1 {
		return
	}
	atomic.AddInt32(RunSum.XtBack, delta)
}
func AddServerCmd(delta int32) {
	if delta < 0 && *RunSum.ServerCmd < 1 {
		return
	}
	atomic.AddInt32(RunSum.ServerCmd, delta)
}
func AddServerCmdConfirm(delta int32) {
	if delta < 0 && *RunSum.ServerCmdConfirm < 1 {
		return
	}
	atomic.AddInt32(RunSum.ServerCmdConfirm, delta)
}
